package com.pay.cloud.activity;

import android.content.Intent;
import android.os.Bundle;

import com.pay.cloud.KeyInfo;
import com.pay.cloud.R;
import com.pay.cloud.fragment.DeviceInfoFragment;
import com.pay.cloud.fragment.SystemFragment;
import com.pay.cloud.fragment.TipVerticalFragment;

import static com.pay.cloud.KeyInfo.KEY_CANCEL;
import static com.pay.cloud.KeyInfo.KEY_ENTER;
import static com.pay.cloud.KeyInfo.KEY_NUM_1;
import static com.pay.cloud.KeyInfo.KEY_NUM_2;
import static com.pay.cloud.KeyInfo.KEY_NUM_3;
import static com.pay.cloud.KeyInfo.KEY_NUM_4;
import static com.pay.cloud.KeyInfo.KEY_NUM_5;
import static com.pay.cloud.fragment.TipFragment.TipType.ERROR;

public class SystemActivity extends AbstractActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_system);
        setMainFragment(new SystemFragment());
    }

    @Override
    public boolean onKeyDown(KeyInfo keyInfo) {
        if (keyInfo == KEY_ENTER || keyInfo == KEY_CANCEL) {
            if (mainFragment instanceof SystemFragment) {
                Intent intent = new Intent(this, SettingActivity.class);
                startActivity(intent);
            } else {
                setMainFragment(new SystemFragment());
            }
        } else if (keyInfo == KEY_NUM_1) {
            Intent intent = new Intent(this, SoundActivity.class);
            startActivity(intent);
        } else if (keyInfo == KEY_NUM_2) {
            Intent intent = new Intent(this, PasswordActivity.class);
            startActivity(intent);
        } else if (keyInfo == KEY_NUM_3) {
            setMainFragment(new TipVerticalFragment(ERROR, "功能暂不支持"));
        } else if (keyInfo == KEY_NUM_4) {
            setMainFragment(new DeviceInfoFragment());
        } else if (keyInfo == KEY_NUM_5) {
            Intent intent = new Intent(this, UpdateActivity.class);
            startActivity(intent);
        }
        return false;
    }

}
